#!/usr/lib/python
# author: koopa516@gmail.com
# python 3.4.1

# Even Fibonacci numbers: Euler 2

### CONFIG
fibonacci = [1, 2] # Fibonacci Numbers
efibonacci = [] # Even Fibonacci Numbers
x = 1 # Fibonacci Sequence: Fn:2 = {1 : if n = 1;}
y = 2 # Fibonacci Sequence: Fn:2 = {1 : if n = 1;}
###

### ALGORITHM
while True:
    if (x > 4000000): break; # Set limit to 4000000
    else:
        x += y # Fibonacci Sequence: Fn:3 = {Fn-1 + Fn-2 : if n > 1.}
        y += x # Fibonacci Sequence: Fn:3 = {Fn-1 + Fn-2 : if n > 1.}
        if (x > 4000000): break; # Set limit to 4000000
        else: pass;
        if (y > 4000000): break; # Set limit to 4000000
        else: pass;
    fibonacci.append(x) # Add Fn-1 to "fibonacci"
    fibonacci.append(y) # Add Fn-2 to "fibonacci"

for eveninteger in fibonacci: # Iterate through "fibonacci"
            if (eveninteger % 2 == 0): # Check curent iteration for evenness
                efibonacci.append(eveninteger) # Add "eveninteger" (All even integers in "fibonacci") to "efibonacci"
###


### OUTPUT
## DEBUG
print(fibonacci)
print(sum(fibonacci))
print(efibonacci)
##
print(sum(efibonacci))
###
###
